package com.wyz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wyz.model.OutStorage;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author wk
 * @desc
 * @date 2024/7/26 15:24
 */
public interface OutStorageMapper extends BaseMapper<OutStorage> {
    @Select("SELECT o.*, i.goods_name,i.goods_sprecification,i.supplierCompany,i.goods_barcode  FROM t_outstorage o JOIN t_inventory i ON o.inventory_id = i.inventory_id")
    List<Map<String, Object>> selectOutStorageWithInventory();
    @Select("SELECT o.*, i.goods_name,i.goods_sprecification,i.supplierCompany,i.goods_barcode  FROM t_outstorage o JOIN t_inventory i ON o.inventory_id = i.inventory_id WHERE o.outstorage_id =#{id}")
    List<Map<String, Object>> selectOutStorageWithInventoryById(Integer id);
    @Select("SELECT o.*, i.goods_name,i.goods_sprecification,i.supplierCompany,i.goods_barcode  FROM t_outstorage o JOIN t_inventory i ON o.inventory_id = i.inventory_id " +
            "WHERE o.outstorage_id LIKE CONCAT('%', #{condition}, '%') " +
            "OR o.inventory_id LIKE CONCAT('%', #{condition}, '%') " +
            "OR i.goods_barcode LIKE CONCAT('%', #{condition}, '%') " +
            "OR o.outstoragePerson LIKE CONCAT('%', #{condition}, '%') " +
            "OR i.supplierCompany LIKE CONCAT('%', #{condition}, '%') " +
            "OR i.goods_name LIKE CONCAT('%', #{condition}, '%') " +
            "OR i.goods_sprecification LIKE CONCAT('%', #{condition}, '%') " +
            "OR o.outstorageRemark LIKE CONCAT('%', #{condition}, '%') " +
            "ORDER BY #{sort} DESC")
    List<Map<String, Object>> selectOutStorageWithInventoryLikeCondition(String condition, String sort);
}
